﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class Services_getThematicMap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        Response.Charset = "utf-8";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");


        string result = String.Empty;
        //string strResultXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\n";
        //strResultXml += "<IPADDRESS>" + "/n";

        result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (null == result || result == String.Empty)
        {
            result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
        }

        if (null == result || result == String.Empty)
        {
            result = HttpContext.Current.Request.UserHostAddress;
        }

        if (null == result || result == String.Empty )
        {
            result = "0.0.0.0";
        }

        string strResultXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\n";
        strResultXml += "<IPADDRESS>" + "\n";
        strResultXml += "<IP>" + result + "</IP> \n";
        strResultXml += "</IPADDRESS>" + "\n";
        Response.Write(strResultXml);

        //Response.Write(result);


    }
}
